#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import os
import random
import time
from multiprocessing import Process, Queue, current_process

"""
    正常顺序执行
"""
def product(q):
    for i in range(10):
        time.sleep(0.5)
        print("{} 生产了包子{}".format(os.getpid(), i))
        q.put(i)
        consume(q)


def consume(q):
    time.sleep(1.5)
    print("{} 吃掉了 包子{}".format(os.getpid(), q.get()))


if __name__ == '__main__':
    q = Queue()
    p = Process(target=product, args=(q,))
    p.start()